package com.yuanian.ecsplus.test;

import java.lang.reflect.Field;

class Person {
    private String name;

    public String getName() {
        return name;
    }

    public void setName(String name) {
        this.name = name;
    }
}
public class Demo3 {

    public static void main(String[] args) {
        Class clz = Person.class;

        long s = System.currentTimeMillis();
        for (int i = 0; i < 10000000; i++) {
            Person p = new Person();
            //p.setName("xxx");
            try {
                Field f = clz.getDeclaredField("name");
                f.setAccessible(true);
                f.set(p, "xxx");
            } catch (Exception e) {
                e.printStackTrace();
            }
        }
        long e = System.currentTimeMillis();
        System.out.println(e - s);

    }
}
